/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Logica;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author User
 */
@Entity
@Table(name = "compite")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Compite.findAll", query = "SELECT c FROM Compite c"),
    @NamedQuery(name = "Compite.findByIdDeportista", query = "SELECT c FROM Compite c WHERE c.compitePK.idDeportista = :idDeportista"),
    @NamedQuery(name = "Compite.findByIdCompetencia", query = "SELECT c FROM Compite c WHERE c.compitePK.idCompetencia = :idCompetencia"),
    @NamedQuery(name = "Compite.findByPuntaje", query = "SELECT c FROM Compite c WHERE c.puntaje = :puntaje"),
    @NamedQuery(name = "Compite.findByFase", query = "SELECT c FROM Compite c WHERE c.fase = :fase")})
public class Compite implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected CompitePK compitePK;
    @Column(name = "puntaje")
    private Integer puntaje;
    @Column(name = "fase")
    private String fase;
    @JoinColumn(name = "id_deportista", referencedColumnName = "id_deportista", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Deportista deportista;
    @JoinColumn(name = "id_competencia", referencedColumnName = "id_competencia", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Competencia competencia;

    public Compite() {
    }

    public Compite(CompitePK compitePK) {
        this.compitePK = compitePK;
    }

    public Compite(String idDeportista, String idCompetencia) {
        this.compitePK = new CompitePK(idDeportista, idCompetencia);
    }

    public CompitePK getCompitePK() {
        return compitePK;
    }

    public void setCompitePK(CompitePK compitePK) {
        this.compitePK = compitePK;
    }

    public Integer getPuntaje() {
        return puntaje;
    }

    public void setPuntaje(Integer puntaje) {
        this.puntaje = puntaje;
    }

    public String getFase() {
        return fase;
    }

    public void setFase(String fase) {
        this.fase = fase;
    }

    public Deportista getDeportista() {
        return deportista;
    }

    public void setDeportista(Deportista deportista) {
        this.deportista = deportista;
    }

    public Competencia getCompetencia() {
        return competencia;
    }

    public void setCompetencia(Competencia competencia) {
        this.competencia = competencia;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (compitePK != null ? compitePK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Compite)) {
            return false;
        }
        Compite other = (Compite) object;
        if ((this.compitePK == null && other.compitePK != null) || (this.compitePK != null && !this.compitePK.equals(other.compitePK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Logica.Compite[ compitePK=" + compitePK + " ]";
    }
    
}
